const express = require('express')
const app = express()
const axios = require('axios')
const jwt = require('jsonwebtoken')

app.use(express.static('./public'))

app.get('/',(req,res) => {
    res.send({err:0,status:200})
})
app.get('/test',(req,res) => {
    axios.get('http://v.juhe.cn/toutiao/index?type=top&key=e1c242e4a5516a6cced459a4a7e73f83')
    .then(result => {
        res.send({msg:result.data})
    })
})
app.get('/server',(req,res) => {
    jwt.sign({name:'张三',pwd:'123456'},"333333333333",(err,result) => {
        if (err) return res.send({err: 1, msg: '登录失败'})
        res.send({err:0,msg:result})
    })
})
app.listen(3000,()=>{
    console.log('http://127.0.0.1:3000')
    
})